import requests
import json
import parsel

url = 'https://www.taopiaopiao.com/showList.htm?spm=a1z21.3046609.header.4.5383112alxgpQK&n_s=new'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
    'Referer': 'https://www.taopiaopiao.com/?tbpm=3',
    'Priority': 'u=0, i',
    'Upgrade-Insecure-Requests': '1',
    'Sec-Ch-Ua-Platform': '"Windows"',
    # '': '',
}

res = requests.get(url, headers=headers)
sele = parsel.Selector(res.text)
detail_urls = sele.css('.movie-card-wrap>a.movie-card::attr(href)').get()
# print(detail_urls)
# for detail_url in detail_urls:
#     print(detail_url)


def get_one_movie(detail_url):
    response = requests.get(detail_url, headers=headers)
    selector = parsel.Selector(response.text)
    show_name = selector.css('.cont-title::text').get()
    # show_name_en = ''
    # bgp = selector.css('.cont-pic>img::attr(src)').get()
    # director = selector.css('.cont-info>li:nth-child(1)::text').get().split('：')[1]
    # main_acts = selector.css('.cont-info>li:nth-child(2)::text').get().split('：')[1]
    # type = selector.css('.cont-info>li:nth-child(3)::text').get().split('：')[1]
    # country = selector.css('.cont-info>li:nth-child(4)::text').get().split('：')[1]
    # duration = selector.css('.cont-info>li:nth-child(5)::text').get().split('：')[1]
    # release = selector.css('.cont-time::text').get().split('：')[1]
    # intro = selector.css('.J_shrink.shrink::text').get().split('：')[1]

    projection = selector.css('td.hall-type::text').get().split(' ')[1]
    language = selector.css('td.hall-type::text').get().split(' ')[0]
    print('show_name', show_name)
    # print('', show_name_en)
    # print('bgp', bgp)
    # print('director', director)
    # print('main_acts', main_acts)
    # print('type', type)
    # print('country', country)
    # print('duration', duration)
    # print('release', release)
    # print('intro', intro)

    print(projection)
    print(language)






get_one_movie(detail_urls)